<?php
use account\Account;
use account\Credit;
use account\Deposit;
use bank\Bank;
use bank\BankUtils;
use client\Client;

include 'bank\Bank.php';
include 'client\Client.php';
include 'account\Deposit.php';
include 'bank\BankUtils.php';
include 'account\Credit.php';

try {
	
	$bankProducts = array ();
	
	$bank1 = new Bank ( "MyBank", "Sofia, 64, Vasil Levski blvd", $bankProducts, 1000000 ); // 5 obrazcovata banka
	
	$client1 = new Client ( "Petya", "Sofia, 23, Ivan Vazov str", 5000, 1000 ); // 6-1-te klienti
	$client2 = new Client ( "Stoyan", "Sofia, 10, Zelena Polyana str", 4000, 1200 );
	$client3 = new Client ( "Martin", "Sofia, 22, Kostenski Vodopad str", 1000, 1200 );
	$client4 = new Client ( "Inna", "Varna, bl. 30, entr. B, Hristo Botev blvd", 10000, 700 );
	$client5 = new Client ( "Maria", "Sofia, 16, Stara Planina str", 3300, 1200 );
	$client6 = new Client ( "Milen", "Sofia, 13, Maritsa str", 4050, 800 );
	$client7 = new Client ( "Krasi", "Bourgas, 10, Morska str", 3300, 1150 );
	$client8 = new Client ( "Daniel", "Sofia, 11B, Ivan Geshov blvd", 800, 1115 );
	$client9 = new Client ( "Gabriela", "Sofia, 65, Arsenalski blvd", 4000, 1035 );
	$client10 = new Client ( "Gergana", "Plovdiv, 7, Ivan Vazov str", 5600, 1700 );
	
	$clients = array (
			$client1,
			$client2,
			$client3,
			$client4,
			$client5,
			$client6,
			$client7,
			$client8,
			$client9,
			$client10 
	);
	
	foreach ( $clients as $client ) { // 7depositi za vsichki
		$percentDepositMoney = rand ( 80, 100 ) / 100;
		$depositMoney = $client->getCash () * $percentDepositMoney;
		
		$client->makeDeposit ( $bank1, new Deposit ( 'Short Deposit', 10, 10, $depositMoney ) );
	}
	
	echo "<br>The bank balance after making client deposits is: " . $bank1->getBalance (); // 8bank info
	echo "<br>The bank reserve after the deposits is: " . $bank1->getBalance () / 10;
	
	foreach ( $clients as $client ) { // 9 razdava krediti kato ktb
		$client->askForCredit ( $bank1, new Credit ( 'Home Credit', rand ( 1, 10 ), rand ( 1, 55 ), rand ( 1000, 3000 ) ) );
	}
	
	echo $bank1; // 10 - izkarva informaciq za bankata, no e zakomentirano, za da se vidi ostanaloto
	
	foreach ( $clients as $client ) { // izkarva informaciq za vseki klient
		echo $client;
	} 

}catch ( Exception $e ) {
	echo $e->getMessage ();
}
